/* eslint-disable */
import { MENU_CODES, METHOD_TYPE, MODULES } from '@/options';
import useBaseRequest from '@/hooks/useBaseRequest';
import { request } from '@umijs/max';
import { ResultList } from '@/types/common/request';

type DataType = DICT_TYPE.Info;
type Params = DICT_TYPE.Params;
const ApiUrl = `/${MODULES.SYSTEM}/${MENU_CODES.DICT}`;

export const { getList, addItem, updateItem, delItem, detailItem } = useBaseRequest<
  DataType,
  Params
>(ApiUrl);

export const getDictByCode = (code: string, options?: { [key: string]: any }) => {
  return request<ResultList<DataType>>(ApiUrl + '/listByCode', {
    method: METHOD_TYPE.GET,
    params: {
      code,
    },
    ...(options || {}),
  });
};
